<template>
  <div style="width: 800px;margin: 100px auto;height: 280px">
    <h2 style="text-align: left">上传文件</h2>
  <el-upload
      v-model:file-list="fileList"
      class="upload-demo"
      action="http://localhost:9877/uploadFiles"
      ref="upload"
      :on-preview="handlePreview"
      drag
      :before-preview="handlePreview"
      :on-remove="handleRemove"
      multiple
      :on-exceed="handleExceed"
      :file-list="fileList"
      :show-file-list="false"
  >
    <el-icon class="el-icon--upload"><upload-filled /></el-icon>
    <template #tip>
      <div class="el-upload__tip">
        请点击或者拖动以上传文件，文件不要太大
      </div>
    </template>
    <div class="el-upload__text">
    <em>请上传文件</em>
    </div>

  </el-upload>
  </div>
</template>

<script>
  import { UploadFilled } from '@element-plus/icons-vue'
  import { ElMessage, ElMessageBox } from 'element-plus'
  import { UploadProps, UploadUserFile } from 'element-plus'
export default {
  name: "Upload",
  components: {
    UploadFilled,
  },

  data() {
    return {
      fileList: [
        {
          name: '',
          url: '',
        },
      ],
    }
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList)
    },
    handlePreview(file) {
      console.log(file)
    },
    handleExceed(files, fileList) {
      this.$message.warning(
          `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
              files.length + fileList.length
          } 个文件`
      )
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    },
  },
}
</script>

<style scoped>

</style>